//
//  HHAppUtils.m
//  pod
//
//  Created by Basic on 15/5/18.
//  Copyright (c) 2015年 green. All rights reserved.
//

#import "HHAppUtils.h"
#import "sys/utsname.h"

@implementation HHAppUtils

#pragma mark - public
+ (NSString*)version
{
    NSDictionary* bundleInfo = [[NSBundle mainBundle] infoDictionary];
    return [bundleInfo valueForKey:@"CFBundleShortVersionString"];
}

+ (NSString*)build
{
    NSDictionary* bundleInfo = [[NSBundle mainBundle] infoDictionary];
    return [bundleInfo valueForKey:(NSString*)kCFBundleVersionKey];
}

+ (NSString*)bundleId
{
    NSDictionary* bundleInfo = [[NSBundle mainBundle] infoDictionary];
    return [bundleInfo valueForKey:(NSString*)kCFBundleIdentifierKey];
}

+ (NSString*)bundleName
{
    NSDictionary* bundleInfo = [[NSBundle mainBundle] infoDictionary];
    return [bundleInfo valueForKey:(NSString*)kCFBundleNameKey];
}

+ (NSString*)applicationName
{
    NSDictionary* bundleInfo = [[NSBundle mainBundle] infoDictionary];
    return [bundleInfo valueForKey:@"CFBundleDisplayName"];
}

+ (NSString *)appLanguage
{
    NSArray *languages = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"];
    NSString *currentLanguage = [languages firstObject];
    if ([currentLanguage hasPrefix:@"zh"]) {
        if ([currentLanguage rangeOfString:@"Hans"].location != NSNotFound) {
            return @"hh_CN";
        }else{
            return @"hh_TW";
        }
    }else{
        return @"en_US";
    }
}

#pragma mark -Device
+ (NSString *)deviceSystemName
{
    return [[UIDevice currentDevice] systemName];
}

+ (NSString *)deviceSystemVersion
{
    return [[UIDevice currentDevice] systemVersion];
}

#pragma maek - 十六位随机字符
+ (NSString *)hh_ret16bitString
{
    int legth = 16;
    char data[legth];
    
    for (int x=0;x<legth;data[x++] = (char)('A' + (arc4random_uniform(26))));
    return [[NSString alloc] initWithBytes:data length:legth encoding:NSUTF8StringEncoding];
}
@end
